import requests

from common.client import RequestsClient
from common.file_load import load_yaml_file


class BaseBuyerApi(RequestsClient):
    #既然买家n多个接口都要用到token,那干脆我在父类中定义一个类属性
    buyer_token =''#定义是空，调用接口前先调用登录接口
    buyer_uid=''
    def __init__(self):
        super().__init__()
        self.session = requests.session()
        self.host =load_yaml_file('/config/http.yml')['buyer']
        self.headers = {
            "Authorization": BaseBuyerApi.buyer_token
        }
    #     self.method =None
    #     self.data =None
    #     self.params =None
    #     self.json = None
    #     self.files =None
    #     self.url=None
    # def send(self,**kwargs):
    #     #并不是所有接口是data参数,也可能是其他参数
    #     #判断下接口请求的各项信息，在kwargs中有没有，如果没有就用对象自身的各个属性
    #     if 'url' not in kwargs:
    #         kwargs['url']=self.url
    #     if 'method' not in kwargs:
    #         kwargs['method']=self.method
    #     if 'headers'not in kwargs:
    #         kwargs['headers'] = self.headers
    #     if 'data' not in kwargs:
    #         kwargs['data'] = self.data
    #     if 'json' not in kwargs:
    #         kwargs['json'] = self.json
    #     if 'params'not in kwargs:
    #         kwargs['params']= self.params
    #     if 'files'not in kwargs:
    #         kwargs['files']=self.files
    #     self.resp=self.session.request(method=self.method,
    #                          url=self.url,
    #                          headers=self.headers,
    #                          data=self.data)
    #     return self.resp

class BaseSellerApi(RequestsClient):
    #既然买家n多个接口都要用到token,那干脆我在父类中定义一个类属性
    seller_token =''#定义是空，调用接口前先调用登录接口
    def __init__(self):
        super().__init__()
        self.session = requests.session()
        self.host =load_yaml_file('/config/http.yml')['seller']
        self.headers = {
            "Authorization": BaseSellerApi.seller_token
        }
    #     self.method =None
    #     self.data =None
    #     self.params =None
    #     self.json = None
    #     self.files =None
    #     self.url=None
    # def send(self,**kwargs):
    #     #并不是所有接口是data参数,也可能是其他参数
    #     #判断下接口请求的各项信息，在kwargs中有没有，如果没有就用对象自身的各个属性
    #     if 'url' not in kwargs:
    #         kwargs['url']=self.url
    #     if 'method' not in kwargs:
    #         kwargs['method']=self.method
    #     if 'headers'not in kwargs:
    #         kwargs['headers'] = self.headers
    #     if 'data' not in kwargs:
    #         kwargs['data'] = self.data
    #     if 'json' not in kwargs:
    #         kwargs['json'] = self.json
    #     if 'params'not in kwargs:
    #         kwargs['params']= self.params
    #     if 'files'not in kwargs:
    #         kwargs['files']=self.files
    #     self.resp=self.session.request(method=self.method,
    #                          url=self.url,
    #                          headers=self.headers,
    #                          data=self.data)
    #     return self.resp
class BaseManagerApi(RequestsClient):
    #既然管理员n多个接口都要用到token,那干脆我在父类中定义一个类属性
    manager_token =''#定义是空，调用接口前先调用登录接口
    def __init__(self):
        super().__init__()
        self.session = requests.session()
        self.host = load_yaml_file('/config/http.yml')['manager']
        self.headers = {
            "Authorization": BaseManagerApi.manager_token
        }
class BaseBasicApi(RequestsClient):
    #既然管理员n多个接口都要用到token,那干脆我在父类中定义一个类属性
    manager_token =''#定义是空，调用接口前先调用登录接口
    def __init__(self):
        super().__init__()
        self.session = requests.session()
        self.host =load_yaml_file('/config/http.yml')['basic']
